/*
派生类对基类成员重新定义：
通过派生类的对象调用一个被重新定义过的基类的成员函数，被调用的是派生类的成员函数；
此时，若想调用基类的同名成员函数，必须在成员函数名前加基类名和作用域运算符“::”。

【3】本例中分别定义一个描述圆的类Ccircle和一个描述圆柱体的类Ccylinder。 
*/
#include <iostream>

using namespace std; 

class Circle {
	protected:
		int x, y;
		int radius;
	
	public:
		void set(int x, int y, int radius);
};

void Circle::set(int x, int y, int radius) {
	this->x = x;
	this->y = y;
	this->radius = radius;
}

class Cylinder : virtual public Circle {
	private:
		int height;

	public:
		void set(int x, int y, int radius, int height);
		friend ostream & operator << (ostream & os, const Cylinder &);
};

void Cylinder::set(int x, int y, int radius, int height) {
	Circle::set(x, y, radius);
	this->height = height;
}

ostream & operator << (ostream & os, const Cylinder & obj) {
	os << "(" << obj.x << "," << obj.y << ")\n";
	os << "Radius: " << obj.radius << endl;
	os << "Height: " << obj.height;

	return os;
}

int main(int argc, char * argv[]) {
	Cylinder cylinder;

	cylinder.set(10, 20, 30, 40);
	cout << cylinder << endl;

	return 0;
}
